﻿using System.Windows;
using System.Windows.Input;
using YSGetLatest.DataObjects;
using YSGetLatest.ViewModels;

namespace YSGetLatest
{
	/// <summary>
	/// Interaction logic for MainWindow.xaml
	/// </summary>
	public partial class MainWindow : Window
	{
		#region Fields

		private readonly MainWindowViewModel mainWindowViewModel_;
		#endregion

		/// <summary>
		/// 
		/// </summary>
		public MainWindow()
		{
			InitializeComponent();

			mainWindowViewModel_ = new MainWindowViewModel(this, listBoxProjects);

			DataContext = mainWindowViewModel_;
		}

		private void MenuItemAbout_Click(object sender, RoutedEventArgs e)
		{
			(new AboutWindow()
			{
				Owner = this
			}).Show();
		}

		private void ListBoxProjects_MouseDoubleClick(object sender, MouseButtonEventArgs e)
		{
			if (mainWindowViewModel_.OpenProjectCommand.CanExecute(e))
			{
				mainWindowViewModel_.OpenProjectCommand.Execute(e);
			}
		}
	}
}
